
import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;
 
@ccclass('CharacterController')
export class CharacterController extends Component {

    private _SPHealthBar: Sprite = null;
    private _SPPercent: Sprite = null;

    onLoad () {
        var nodeHealthBar = this.node.getChildByName("HealthBar");

        this._SPHealthBar = nodeHealthBar.getComponent(Sprite);
        this._SPPercent = nodeHealthBar.getChildByName("Percent").getComponent(Sprite);
    }

    start () {
    }

    setBlood (nPercent: number) {
        this._SPPercent.fillRange = nPercent;
    }

    setBloodVisible (flag: boolean) {
        this._SPHealthBar.node.active = flag;
    }

    setBloodSpriteFrame (spriteFrame: SpriteFrame) {
        this._SPPercent.spriteFrame = spriteFrame;
    }

}
